#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // connect(发出信号的对象, 发出的信号, 处理信号的对象, 处理信号的函数)
    connect(ui->push_button_01, &QPushButton::clicked, this, &Widget::close);

    // 自定义处理函数
    connect(ui->push_button_01, &QPushButton::clicked, this, [=]() {
        qDebug() << "Close Button Was Clicked!" << endl;
    });

    // 信号连接信号
    connect(ui->push_button_01, &QPushButton::clicked, this, &Widget::saveData);

    // 自定义信号和自定义槽函数的连接
    connect(this, &Widget::saveData, this, &Widget::saveDataToMysql);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::saveDataToMysql() {
    qDebug() << "Mysql Save Data Success";
}
